<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of diadiemhoc_model
 *
 * @author Trung
 */
class M_sinhvien extends CI_Model {

    private $_name_table = 'tbl_sinhvien';
    private $_Ma_SV = 'Ma_SV';

    public function __construct() {
        parent::__construct();
    }

    public function getID() {
        $this->db->select_max($this->_Ma_SV);
        $query = $this->db->get($this->_name_table);
        $data = $query->row_array();
        $id = $data->_Ma_SV;

        if (strlen($id) == 0) {
            $id = 'CB0000';
        }
        $id++;

        return $id;
    }

    public function getSinhVien($maos) {
        $this->db->where($this->_MaSo, $maso);
        $query = $this->db->get($this->_name_table);
        $data = $query->row_array();
        return $data;
    }

    public function getAll() {
        return $this->db->get('tbl_sinh_vien')->result_array();
    }

    public function getLike($key) {

      
        $this->db->or_like('HoTen_SV', $key);
        $this->db->or_like('Lop_SV', $key);       
        $this->db->from('tbl_sinh_vien');  
        $query = $this->db->get();       
        return $query->result_array();
    }

}

?>
